package com.app.business.web.business;

import com.app.business.calculate.CalculateHandInMoneyUtils;
import com.app.business.calculate.CalculateUtils;
import com.app.business.en.Status;
import com.app.business.model.*;
import com.app.business.service.*;
import com.app.system.jpa.PageBean;
import com.app.system.permission.model.DataDict;
import com.app.system.permission.service.DataDictService;
import com.app.system.utils.CollectionUtils;
import com.app.system.utils.ParamUtils;
import com.app.system.utils.WebUtils;
import com.app.system.utils.dataType.BigDecimalUtils;
import com.app.system.utils.dataType.DateUtils;
import com.app.system.utils.dataType.IntegerUtils;
import com.app.system.utils.dataType.StringUtils;
import com.app.system.utils.exception.AjaxException;
import com.app.system.utils.exception.Precondition;
import com.app.system.utils.exception.Response;
import com.app.system.utils.page.LayUiUtils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.*;

/**
 * 财务数据管理
 * Created by lsh on 2019/2/14.
 *
 * @author lsh
 */
@Controller
@RequestMapping("/business/finance/*")
@SuppressWarnings("all")
public class FinanceController {

    @Autowired
    private ContractService contractService;
    @Autowired
    private DataDictService dataDictService;
    @Autowired
    private ZsProjectService zsProjectService;
    @Autowired
    private HandInMoneyService handInMoneyService;
    @Autowired
    private HouseService houseService;
    @Autowired
    private CarLotService carLotService;
    @Autowired
    private StorageRoomService storageRoomService;
    @Autowired
    private ActionHistoryService actionHistoryService;
    @Autowired
    private BuyHousePersonService buyHousePersonService;
    @Autowired
    private ShopHouseService shopHouseService;
    @Autowired
    private ParameterService parameterService;
    @Autowired
    private OverAreaPriceNewService overAreaPriceNewService;
    @Autowired
    private SyKgInfoService syKgInfoService;

    /**
     * 财务复核管理列表
     */
    @RequestMapping("list")
    @RequiresPermissions("finance:list")
    public void list() {
    }

    /**
     * 财务数据复核管理列表
     */
    @RequestMapping("fhList")
    @RequiresPermissions("finance:fhList")
    public void fhList() {
    }

    /**
     * 加载财务复核数据管理列表
     *
     * @return
     */
    @RequestMapping("loadFinanceList")
    @ResponseBody
    @RequiresPermissions("finance:loadFinanceList")
    public Map loadContractList() {
        List<Map> listData = Lists.newArrayList();
        PageBean<Contract> contractPageBean = this.contractService.getChoosedHousePageBean();
        List<Contract> contractList = contractPageBean.getDatas();
        Map<String, DataDict> signMap = this.dataDictService.getMapByParentNameForValue("签约状态");
        Map<String, DataDict> checkMap = this.dataDictService.getMapByParentNameForValue("复核状态");
        Map<String, DataDict> sfMap = this.dataDictService.getMapByParentNameForValue("司法状态");
        Map<String, DataDict> townMap = this.dataDictService.getMapByParentNameForValue("乡镇");
        Map<String, DataDict> jyMoneyFfStatusMap = this.dataDictService.getMapByParentNameForValue("档案发放状态");
        if (!CollectionUtils.isEmpty(contractList)) {
            Map<String, Object> item = null;
            for (Contract contract : contractList) {
                item = null;
                item = Maps.newHashMap();
                item.put("id", contract.getId());
                item.put("town", StringUtils.dataDictShow(townMap.get(contract.getZsProject().getTown())));
                item.put("zsProjectName", contract.getZsProject().getProjectName());
                item.put("contractCode", StringUtils.getNotNull(contract.getContractCode()));
                item.put("name", StringUtils.getNotNull(contract.getName()));
                item.put("chooseHouseNum", StringUtils.getNotNull(contract.getChooseHouseNum()));
                item.put("limitHouseAreaTotal", BigDecimalUtils.getNotNullStr(contract.getLimitHouseAreaTotal()));
                item.put("financeCheckStatus", IntegerUtils.getNotNull(contract.getFinanceCheckStatus()));
                item.put("financeCheckStatusStr", StringUtils.dataDictShow(checkMap.get(IntegerUtils.getNotNull(contract.getFinanceCheckStatus()).toString())));
                item.put("azSignStatus", IntegerUtils.getNotNull(contract.getAzSignStatus()));
                item.put("azSignStatusStr", StringUtils.dataDictShow(signMap.get(IntegerUtils.getNotNull(contract.getAzSignStatus()).toString())));
                item.put("azType",contract.getAzType());
                item.put("jyMoneyFfStatus",contract.getJyMoneyFfStatus());
                item.put("sfStatus",contract.getSfStatus());
                item.put("jyMoneyFfStatusStr", StringUtils.dataDictShow(jyMoneyFfStatusMap.get(String.valueOf(contract.getJyMoneyFfStatus()))));
                item.put("sfStatusStr", StringUtils.dataDictShow(sfMap.get(String.valueOf(contract.getSfStatus()))));

                listData.add(item);
            }
        }
        return LayUiUtils.page(contractPageBean.getTotalCount().intValue(), listData);
    }


    /**
     * 财务结算表/缴款通知书/缴款清单打印页面
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("financePrint")
    @RequiresPermissions("finance:financePrint")
    public void settlementPrint(HttpServletRequest request, ModelMap modelMap) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        int contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkSqdsArguement(contract != null, "数据有误");
        BigDecimal resultArea = new BigDecimal("0");
        if (contract.getBuyStorageRoomType() != null && contract.getBuyStorageRoomType() == 1) {
            resultArea = BigDecimalUtils.getSum(contract.getChooseHouseAreaTotal(), BigDecimalUtils.getBigAndBigDiv(contract.getStorageRoomArea(), contract.getParameter().getCwjBl(), 2));
        } else
            resultArea = contract.getChooseHouseAreaTotal();
        /*3800优惠面积*/
        BigDecimal overArea = BigDecimal.ZERO;
        BigDecimal xfbcPrice = BigDecimal.ZERO;
        if (contract.getParameter() != null) {
            Parameter parameter = this.parameterService.findOne(contract.getParameter().getId());
            xfbcPrice = parameter.getXfbcPrice();
            if (parameter != null && parameter.getName() != null) {
                overArea = this.parameterService.getOverArea(parameter.getId());
                if (contract.getXcOrJcNum() > 0 && parameter.getId() == 2594) {//若存在析产则节点优惠面积除以 数量
                    if (contract.getIsNoSyYhAreaStatus() == 1) {//若是使用手动添加面积
                        overArea = contract.getYhArea();
                    } else {
                        overArea = BigDecimalUtils.getBigAndBigDiv(new BigDecimal("10"),new BigDecimal(contract.getXcOrJcNum()),2);
                    }
                }
                if (overArea.compareTo(new BigDecimal("9999")) == 0) {
                    overArea = BigDecimal.ZERO;
                }
            }
        }
        modelMap.addAttribute("overArea",overArea);
        modelMap.addAttribute("xfbcPrice",xfbcPrice);

        //选房期临时安置补助计算说明及停产停业计算说明
        String zzgdMoneyMemo = null,zxgdMoneyMemo = null,zzgdMoneyYzMemo = null;
        zzgdMoneyYzMemo = this.zzgdMoneyYzMemo(contract);
        zzgdMoneyMemo = this.zzgdMoneyMemo(contract);
        zxgdMoneyMemo = this.zxgdMoneyMemo(contract);
        modelMap.addAttribute("zzgdMoneyMemo",zzgdMoneyMemo);
        modelMap.addAttribute("zxgdMoneyMemo",zxgdMoneyMemo);
        modelMap.addAttribute("zzgdMoneyYzMemo",zzgdMoneyYzMemo);

        //选房期临时安置补助计算费用及停产停业计算费用
        BigDecimal zzgdMoney = BigDecimal.ZERO,zxgdMoney = BigDecimal.ZERO;
        zzgdMoney = this.zzgdMoney(contract);
        zxgdMoney = this.zxgdMoney(contract);
        modelMap.addAttribute("zzgdMoney",zzgdMoney);
        modelMap.addAttribute("zxgdMoney",zxgdMoney);

        //其它
        modelMap.addAttribute("contract", contract);
        modelMap.addAttribute("resultArea", resultArea);
        modelMap.addAttribute("tkDate", DateUtils.dateToStringFormat(contract.getTkDate(), "yyyy-MM-dd"));
        CalculateHandInMoneyUtils.main(contract.getId());

    }

    /**
     * 设置审核状态（可退回）
     *
     * @param request
     */
    @RequestMapping("checkStatus")
    @ResponseBody
    @RequiresPermissions("finance:checkStatus")
    public synchronized Response checkStatus(HttpServletRequest request) {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");

        if (contract.getFinanceCheckStatus().equals(Status.NO.getIndex()) || contract.getFinanceCheckStatus().equals(Status.TUI.getIndex())) {
            contract.setFinanceCheckStatus(Status.YES.getIndex());
            contract.setFinanceCheckDate(new Date());
            this.actionHistoryService.saveActionHistoryByContractId(contract.getId(), "设置为财务已审核状态", "财务审核状态");

        } else {
            Precondition.checkAjaxArguement(contract.getFinanceSettleStatus() != null && !contract.getFinanceSettleStatus().equals(Status.YES.getIndex()), "2222", "财务已结算！");
            contract.setFinanceCheckStatus(Status.TUI.getIndex());
            contract.setFinanceCheckDate(new Date());
            this.actionHistoryService.saveActionHistoryByContractId(contract.getId(), "设置为财务审核已退回状态", "财务审核状态");

        }
        this.contractService.save(contract);
        return new Response("0001", "操作成功");
    }

    /**
     * 保存过渡费
     *
     * @param request
     */
    @RequestMapping("setTransitionMoney")
    @ResponseBody
    @RequiresPermissions("finance:setTransitionMoney")
    public synchronized Response setTransitionMoney(HttpServletRequest request) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        String overArea = ParamUtils.getString(request,"overArea","0");//节点优惠面积
        String xfbcPrice = ParamUtils.getString(request,"xfbcPrice","0");//安置不足单价
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");
        WebUtils.bind(request, contract);
        this.contractService.save(contract);
        if (!contract.getZsProject().getProjectName().contains("第二批次")) {//非商业计算执行配置表自动计算功能
            Parameter parameter = this.parameterService.saveParameter(request);
            parameter.setXfbcPrice(BigDecimalUtils.stringToBigDecimal(xfbcPrice));
            this.parameterService.save(parameter);
        }
        CalculateUtils.main(contract.getId());
        return new Response("0001", "保存成功!");
    }


    /**
     * 财务结算数据管理列表
     */
    @RequestMapping("handInMoneyList")
    @RequiresPermissions("finance:handInMoneyList")
    public void handInMoneyList() {
    }

    /**
     * 加载结算财务数据管理列表
     *
     * @return
     */
    @RequestMapping("loadHandInMoneyList")
    @ResponseBody
    @RequiresPermissions("finance:loadHandInMoneyList")
    public Map loadHandInMoneyList() {
        List<Map> listData = Lists.newArrayList();
        PageBean<Contract> contractPageBean = this.contractService.getAzSignAndFhPageBean();
        List<Contract> contractList = contractPageBean.getDatas();
        Map<String, DataDict> signMap = this.dataDictService.getMapByParentNameForValue("签约状态");
        Map<String, DataDict> settleMap = this.dataDictService.getMapByParentNameForValue("财务结清状态");
        Map<String, DataDict> daffMap = this.dataDictService.getMapByParentNameForValue("档案发放状态");
        Map<String, DataDict> townMap = this.dataDictService.getMapByParentNameForValue("乡镇");
        if (!CollectionUtils.isEmpty(contractList)) {
            Map<String, Object> item = null;
            for (Contract contract : contractList) {
                item = null;
                item = Maps.newHashMap();
                item.put("id", contract.getId());
                item.put("town", StringUtils.dataDictShow(townMap.get(contract.getZsProject().getTown())));
                item.put("zsProjectName", contract.getZsProject().getProjectName());
                item.put("contractCode", StringUtils.getNotNull(contract.getContractCode()));
                item.put("name", StringUtils.getNotNull(contract.getName()));
                item.put("chooseHouseNum", StringUtils.getNotNull(contract.getChooseHouseNum()));
                item.put("limitHouseAreaTotal", BigDecimalUtils.getNotNullStr(contract.getLimitHouseAreaTotal()));
                item.put("azSignStatus", IntegerUtils.getNotNull(contract.getAzSignStatus()));
                item.put("azSignStatusStr", StringUtils.dataDictShow(signMap.get(IntegerUtils.getNotNull(contract.getAzSignStatus()).toString())));
                item.put("financeSettleStatus", IntegerUtils.getNotNull(contract.getFinanceSettleStatus()));
                item.put("financeSettleStatusStr", StringUtils.dataDictShow(settleMap.get(IntegerUtils.getNotNull(contract.getFinanceSettleStatus()).toString())));
                item.put("daffStatus", IntegerUtils.getNotNull(contract.getDaffStatus()));
                item.put("daffStatusStr", StringUtils.dataDictShow(daffMap.get(IntegerUtils.getNotNull(contract.getDaffStatus()).toString())));
                listData.add(item);
            }
        }
        return LayUiUtils.page(contractPageBean.getTotalCount().intValue(), listData);
    }


    /**
     * 结清凭证/户型清单/交房通知书打印页面
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("handInMoneyPrint")
    @RequiresPermissions("finance:handInMoneyPrint")
    public void handInMoneyPrint(HttpServletRequest request, ModelMap modelMap) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        int contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkSqdsArguement(contract != null, "数据有误");
        List<House> houseList = new ArrayList<>();
        List<CarLot> carLotList = new ArrayList<>();
        List<StorageRoom> storageRoomList = new ArrayList<>();
        List<ShopHouse> shopHouseList = new ArrayList<>();
        if (contract.getFinalMoney().compareTo(new BigDecimal("0")) < 0) {
            houseList = this.houseService.getHandInMoneyHouseListByContractId(contract.getId());
            carLotList = this.carLotService.getHandInMoneyCarLotListByContractId(contract.getId());
            storageRoomList = this.storageRoomService.getHandInMoneyStorageRoomListByContractId(contract.getId());
            shopHouseList = this.shopHouseService.getHandInMoneyShopHouseListByContractId(contract.getId());

        } else {
            houseList = this.houseService.getHouseListByContractId(contract.getId());
            carLotList = this.carLotService.getCarLotListByContractId(contract.getId());
            storageRoomList = this.storageRoomService.getStorageRoomListByContractId(contract.getId());
            shopHouseList = this.shopHouseService.getShopHouseListByContractId(contract.getId());
        }
        Map<String, List<Map>> buyHousePersonHouseMap = this.buyHousePersonService.getBuyHousePersonByHouse();
        Map<String, List<Map>> buyHousePersonCarLotMap = this.buyHousePersonService.getBuyHousePersonByCarLot();
        Map<String, List<Map>> buyHousePersonStorageRoomMap = this.buyHousePersonService.getBuyHousePersonByStorageRoom();
        Map<String, List<Map>> buyHousePersonShopHouseMap = this.buyHousePersonService.getBuyHousePersonByShopHouse();


        modelMap.addAttribute("contract", contract);
        modelMap.addAttribute("houseList", houseList);
        modelMap.addAttribute("carLotList", carLotList);
        modelMap.addAttribute("storageRoomList", storageRoomList);
        modelMap.addAttribute("shopHouseList", shopHouseList);
        modelMap.addAttribute("buyHousePersonHouseMap", buyHousePersonHouseMap);
        modelMap.addAttribute("buyHousePersonCarLotMap", buyHousePersonCarLotMap);
        modelMap.addAttribute("buyHousePersonStorageRoomMap", buyHousePersonStorageRoomMap);
        modelMap.addAttribute("buyHousePersonShopHouseMap", buyHousePersonShopHouseMap);
        CalculateHandInMoneyUtils.main(contract.getId());


    }

    /**
     * 加载缴款信息
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("handInMoneyRecordList")
    @RequiresPermissions("finance:handInMoneyRecordList")
    public void handInMoneyRecordList(HttpServletRequest request, ModelMap modelMap) {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        Map cwMemoMap= CalculateHandInMoneyUtils.calQiHouseMoney(contract);
        modelMap.addAttribute("cwMemoMap", cwMemoMap);
        modelMap.addAttribute("contract", contract);
    }

    /**
     * 加载缴款信息
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("handInMoney")
    @RequiresPermissions("finance:handInMoney")
    public void handInMoney(HttpServletRequest request, ModelMap modelMap) {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Integer handInMoneyId = ParamUtils.getInt(request, "handInMoneyId", 0);
        Contract contract = this.contractService.findOne(contractId);
        HandInMoney handInMoney = this.handInMoneyService.findOne(handInMoneyId);
        BigDecimal syMoney = BigDecimalUtils.getBigAndBigSub(BigDecimalUtils.getAbsolute(contract.getShouldHandInMoney()), contract.getHandInMoney());
        modelMap.addAttribute("contract", contract);
        modelMap.addAttribute("handInMoney", handInMoney);
        modelMap.addAttribute("syMoney", syMoney);
    }


    /**
     * 登记缴款数据保存
     *
     * @param request
     * @return
     * @throws AjaxException
     */
    @RequestMapping("handInMoneySave")
    @ResponseBody
    @RequiresPermissions("finance:handInMoneySave")
    public synchronized Response handInMoneySave(HttpServletRequest request) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Response response = this.handInMoneyService.handInMoneySave(request);
        return response;
    }

    /**
     * 删除缴款数据
     *
     * @param request
     * @return
     */
    @RequestMapping("delHandInMoneyById")
    @ResponseBody
    @RequiresPermissions("finance:delHandInMoneyById")
    public synchronized Response delHandInMoneyById(HttpServletRequest request) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Integer handInMoneyId = ParamUtils.getInt(request, "handInMoneyId", 0);
        HandInMoney handInMoney = this.handInMoneyService.findOne(handInMoneyId);
        Precondition.checkAjaxArguement(handInMoney != null, "1111", "数据错误！");
        Contract contract = handInMoney.getContract();
        Precondition.checkAjaxArguement(contract != null, "2222", "数据错误！");
        this.handInMoneyService.delete(handInMoney.getId());
        CalculateHandInMoneyUtils.main(contract.getId());
        return new Response("0001", "删除成功!");
    }

    /**
     * 加载缴款记录
     *
     * @return
     */
    @RequestMapping("loadHandInMoneyRecord")
    @ResponseBody
    @RequiresPermissions("finance:loadHandInMoneyRecord")
    public Map loadHandInMoneyRecord(HttpServletRequest request, ModelMap modelMap) {
        List<Map> listData = Lists.newArrayList();
        int contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");
        List<HandInMoney> handInMoneyList = this.handInMoneyService.getHandInMoneyListByContractId(contractId);//缴款记录
        Map<String, DataDict> handInMoneyMap = this.dataDictService.getMapByParentNameForValue("缴款类别");
        if (CollectionUtils.isNotEmpty(handInMoneyList)) {
            Map<String, Object> item = null;
            for (HandInMoney handInMoney : handInMoneyList) {
                item = null;
                item = Maps.newHashMap();
                item.put("id", handInMoney.getId());
                item.put("handInMoneyDate", DateUtils.dateToStringDefault(handInMoney.getHandInMoneyDate()));
                item.put("handInMoneyType", IntegerUtils.getNotNull(handInMoney.getHandInMoneyType()));
                item.put("handInMoneyTypeStr", StringUtils.dataDictShow(handInMoneyMap.get(IntegerUtils.getNotNull(handInMoney.getHandInMoneyType()).toString())));
                item.put("handInMoney", BigDecimalUtils.getNotNullStr(handInMoney.getHandInMoney()));
                item.put("handInMoneyMemo", StringUtils.getNotNull(handInMoney.getHandInMoneyMemo()));
                item.put("contractCode", StringUtils.getNotNull(contract.getContractCode()));
                listData.add(item);
            }
        }
        return LayUiUtils.list(listData);
    }


    /**
     * 设置协议结算状态（可撤销）
     *
     * @param request
     */
    @RequestMapping("setFinanceSettleStatus")
    @ResponseBody
    @RequiresPermissions("finance:setFinanceSettleStatus")
    public synchronized Response setFinanceSettleStatus(HttpServletRequest request) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        String str = null;
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");
        Precondition.checkAjaxArguement(contract.getLimitStatus() != 3, "1111", "该户不可结算交房，请确认无误后联系技术支持修改！");
        BigDecimal syMoney = BigDecimalUtils.getSum(contract.getHandInMoney(), contract.getShouldHandInMoney());
        if (contract.getFinanceSettleStatus().equals(Status.NO.getIndex())) {
            if (contract.getShouldHandInMoney().compareTo(new BigDecimal("0")) < 0) {
                Precondition.checkAjaxArguement(syMoney.compareTo(new BigDecimal("0")) <= 0, "2222", "该户尚未缴清款项,请先登记缴款！");
            }
            contract.setFinanceSettleStatus(Status.YES.getIndex());
            contract.setFinanceSettleDate(new Date());
            str = "设置为财务已结算、档案已发放";
        } else if (contract.getFinanceSettleStatus().equals(Status.YES.getIndex())) {
            Precondition.checkAjaxArguement(contract.getDaffStatus().equals(Status.NO.getIndex()), "2222", "该家庭已签约并发放协议档案，不允许撤销！");
            contract.setFinanceSettleStatus(Status.NO.getIndex());
            contract.setFinanceSettleDate(null);
            str = "设置为财务未结算";

        } else if (contract.getFinanceSettleStatus().equals(Status.TUI.getIndex())) {
            Precondition.checkAjaxArguement(syMoney.compareTo(new BigDecimal("0")) <= 0, "2222", "该户尚未缴清款项,请先登记缴款！");
            contract.setFinanceSettleStatus(Status.YES.getIndex());
            contract.setFinanceSettleDate(new Date());
            str = "设置为财务已结算";
        }
        this.contractService.save(contract);
        this.actionHistoryService.saveActionHistoryByContractId(contract.getId(), str, "财务结算状态");
        this.contractService.setHouseFinanceSettleStatus(contract);
        return new Response("0001", "操作成功");
    }

    /**
     * 财务缴款登记房源、车位管理列表
     */
    @RequestMapping("setHouseSettleStatusList")
    @RequiresPermissions("finance:setHouseSettleStatusList")
    public void setHouseSettleStatusList(HttpServletRequest request, ModelMap modelMap) {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkSqdsArguement(contract != null, "数据有误,请联系技术支持");
        List<House> houseList = this.houseService.getHouseListByContractId(contract.getId());
        List<CarLot> carLotList = this.carLotService.getCarLotListByContractId(contract.getId());
        Map<String, DataDict> houseHoldMap = this.dataDictService.getMapByParentNameForValue("房屋户型");
        Map<String, DataDict> carLotTypeMap = this.dataDictService.getMapByParentNameForValue("车位类型");
        Map<String, DataDict> financeMap = this.dataDictService.getMapByParentNameForValue("财务结清状态");


        modelMap.addAttribute("houseList", houseList);
        modelMap.addAttribute("carLotList", carLotList);
        modelMap.addAttribute("contract", contract);
        modelMap.addAttribute("houseHoldMap", houseHoldMap);
        modelMap.addAttribute("carLotTypeMap", carLotTypeMap);
        modelMap.addAttribute("financeMap", financeMap);
    }


    /**
     * 设置房源结算状态（可撤销）
     *
     * @param request
     */
    @RequestMapping("setHouseFinanceSettleStatus")
    @ResponseBody
    @RequiresPermissions("finance:setHouseFinanceSettleStatus")
    public synchronized Response setHouseFinanceSettleStatus(HttpServletRequest request) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Integer houseId = ParamUtils.getInt(request, "houseId", 0);
        House house = this.houseService.findOne(houseId);
        Integer contractId = house.getContract().getId();
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");
        Precondition.checkAjaxArguement(contract.getLimitStatus() != 3, "1111", "该户不可结算交房，请确认无误后联系技术支持修改！");
        Precondition.checkAjaxArguement(house != null, "1111", "数据错误！");
        this.houseService.setHouseFinanceSettleStatus(house);
        this.contractService.setFinanceSettleStatus(contract);
        return new Response("0001", "操作成功");
    }

    /**
     * 设置车位结算状态（可撤销）
     *
     * @param request
     */
    @RequestMapping("setCarLotFinanceSettleStatus")
    @ResponseBody
    @RequiresPermissions("finance:setCarLotFinanceSettleStatus")
    public synchronized Response setCarLotFinanceSettleStatus(HttpServletRequest request) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Integer carLotId = ParamUtils.getInt(request, "carLotId", 0);
        CarLot carLot = this.carLotService.findOne(carLotId);
        Integer contractId = carLot.getContract().getId();
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");
        Precondition.checkAjaxArguement(contract.getLimitStatus() != 3, "1111", "该户不可结算交房，请确认无误后联系技术支持修改！");
        Precondition.checkAjaxArguement(carLot != null, "1111", "数据错误！");
        this.carLotService.setCarLotFinanceSettleStatus(carLot);
        this.contractService.setFinanceSettleStatus(contract);
        return new Response("0001", "操作成功");
    }


    /**
     * 设置档案状态（不可撤销）
     *
     * @param request
     */
    @RequestMapping("setDaffStatus")
    @ResponseBody
    @RequiresPermissions("finance:setDaffStatus")
    public synchronized Response setDaffStatus(HttpServletRequest request) {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");
        Precondition.checkAjaxArguement(!contract.getDaffStatus().equals(Status.YES.getIndex()), "2222", "该协议档案已发放，不允许撤销！");

        contract.setDaffStatus(Status.YES.getIndex());
        contract.setDaffDate(new Date());

        this.contractService.save(contract);
        this.actionHistoryService.saveActionHistoryByContractId(contract.getId(), "财务结算页面设置为档案已发放", "档案发放状态");

        return new Response("0001", "操作成功");
    }

    /**
     * 设置档案状态（可撤销）
     *
     * @param request
     */
    @RequestMapping("setMoneyStatus")
    @ResponseBody
    public synchronized Response setMoneyStatus(HttpServletRequest request) {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        String str = null;
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");
        if (contract.getJyMoneyFfStatus().equals(Status.NO.getIndex())) {
            contract.setJyMoneyFfStatus(Status.YES.getIndex());

            str = "设置结余费用已发放";
        } else {
            contract.setJyMoneyFfStatus(Status.NO.getIndex());

            str = "设置结余费用未发放";
        }
        this.contractService.save(contract);
        return new Response("0001", "操作成功");
    }

    /**
     * 设置司法状态（可撤销）
     *
     * @param request
     */
    @RequestMapping("setSfStatus")
    @ResponseBody
    public synchronized Response setSfStatus(HttpServletRequest request) {
        Integer contractId = ParamUtils.getInt(request, "contractId", 0);
        String str = null;
        Contract contract = this.contractService.findOne(contractId);
        Precondition.checkAjaxArguement(contract != null, "1111", "数据错误！");
        if (contract.getSfStatus().equals(Status.NO.getIndex())) {
            contract.setSfStatus(Status.YES.getIndex());

            str = "设置走司法";
        } else {
            contract.setSfStatus(Status.NO.getIndex());

            str = "设置正常";
        }
        this.contractService.save(contract);
        return new Response("0001", "操作成功");
    }

    //选房期临时安置补助计算说明及停产停业计算说明zzgdMoneyMemo = null,zxgdMoneyMemo = null;

    /**
     * 住宅过渡费金额计算
     * @param contract
     * @return
     */
    public BigDecimal zzgdMoney(Contract contract) {
        BigDecimal zzgdMoneyPrice = BigDecimal.ZERO;//据实单价(元/月)
        //临时安置补助单价 都是翻倍数据(元/月)
        BigDecimal lsAzBzPrice = BigDecimalUtils.getBigAndBigMul(contract.getLsAzBzPrice(),new BigDecimal("2"));
        //临时安置补助增加部分单价 都是翻倍数据(元/月)
        BigDecimal lsAzBzZjPrice = BigDecimalUtils.getBigAndBigMul(contract.getLsAzBzZjPrice(),new BigDecimal("2"));
        //临时安置补助单价 + 临时安置增加单价
        BigDecimal lsAzBzPriceTotal = BigDecimalUtils.getSum(lsAzBzPrice,lsAzBzZjPrice);

        if (lsAzBzPriceTotal.compareTo(new BigDecimal("1000")) <= 0) {//当总单价小于1000 则实际单价及时合计单价
            zzgdMoneyPrice = lsAzBzPriceTotal;
        } else {
            if (lsAzBzPrice.compareTo(new BigDecimal("1000")) >= 0) {//若是正常单价大于1000 则按正常单价计算
                zzgdMoneyPrice = lsAzBzPrice;
            } else {//若小于1000
                if (lsAzBzPriceTotal.compareTo(new BigDecimal("1000")) > 0) {
                    zzgdMoneyPrice = new BigDecimal("1000");
                } else {
                    zzgdMoneyPrice = lsAzBzPriceTotal;
                }
            }
        }

        //房源签认时间年月日划分  只考虑2024年、2025，其它年份暂不考虑
        Date chooseHouseDate = contract.getChooseHouseDate();//选房时间
        Calendar chooseHouseCal = Calendar.getInstance();
        chooseHouseCal.setTime(chooseHouseDate);
        int chooseYear = chooseHouseCal.get(Calendar.YEAR);//选房年
        int chooseMonth = chooseHouseCal.get(Calendar.MONTH) + 1;//选房月
        int chooseDay = chooseHouseCal.get(Calendar.DATE);//选房日

        YearMonth yearMonth = YearMonth.of(chooseYear,chooseMonth);
        int yearMonthDays = yearMonth.lengthOfMonth();
        //每天单价   每个月一律按30天计算
        BigDecimal dayPrice = BigDecimalUtils.getBigAndBigDiv(zzgdMoneyPrice,new BigDecimal(yearMonthDays),2);

        int zzgdFfMonth = 1;//总需发放月份  就算是9月份选房，也要多发一个月
        if (chooseYear == 2024) { //若2024年
            zzgdFfMonth = zzgdFfMonth + chooseMonth - 9;
        } else if (chooseYear == 2025) { //若是2025年 则2024年9、10、11、12月4个月过渡费都要发放,当月的按天发放；
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1;
        } else {
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1 + (chooseYear - 2025) * 12;
        }

        //总需发放过渡费金额
        BigDecimal zzgdMoney = BigDecimal.ZERO;
        zzgdMoney = BigDecimalUtils.getSum(
                BigDecimalUtils.getBigAndIntMul(dayPrice,chooseDay),
                BigDecimalUtils.getBigAndIntMul(zzgdMoneyPrice,zzgdFfMonth)
        ).setScale(2);
        return zzgdMoney;
    }


    /**
     * 一中住宅过渡费金额计算
     * @param contract
     * @return
     */
    public BigDecimal zzgdMoneyYz(Contract contract) {
        BigDecimal zzgdMoneyPrice = BigDecimal.ZERO;//据实单价(元/月)
        //临时安置补助单价 都是翻倍数据(元/月)
        BigDecimal lsAzBzPrice = BigDecimalUtils.getBigAndBigMul(contract.getLsAzBzPrice(),new BigDecimal("2"));
        //临时安置补助增加部分单价 都是翻倍数据(元/月)
        BigDecimal lsAzBzZjPrice = BigDecimalUtils.getBigAndBigMul(contract.getLsAzBzZjPrice(),new BigDecimal("2"));
        //临时安置补助单价 + 临时安置增加单价
        BigDecimal lsAzBzPriceTotal = BigDecimalUtils.getSum(lsAzBzPrice,lsAzBzZjPrice);

        if (lsAzBzPriceTotal.compareTo(new BigDecimal("1000")) <= 0) {//当总单价小于1000 则实际单价及时合计单价
            zzgdMoneyPrice = lsAzBzPriceTotal;
        } else {
            if (lsAzBzPrice.compareTo(new BigDecimal("1000")) >= 0) {//若是正常单价大于1000 则按正常单价计算
                zzgdMoneyPrice = lsAzBzPrice;
            } else {//若小于1000
                if (lsAzBzPriceTotal.compareTo(new BigDecimal("1000")) > 0) {
                    zzgdMoneyPrice = new BigDecimal("1000");
                } else {
                    zzgdMoneyPrice = lsAzBzPriceTotal;
                }
            }
        }

        //房源签认时间年月日划分  只考虑2024年、2025，其它年份暂不考虑
        Date chooseHouseDate = contract.getChooseHouseDate();//选房时间
        Calendar chooseHouseCal = Calendar.getInstance();
        chooseHouseCal.setTime(chooseHouseDate);
        int chooseYear = chooseHouseCal.get(Calendar.YEAR);//选房年
        int chooseMonth = chooseHouseCal.get(Calendar.MONTH) + 1;//选房月
        int chooseDay = chooseHouseCal.get(Calendar.DATE);//选房日

        YearMonth yearMonth = YearMonth.of(chooseYear,chooseMonth);
        int yearMonthDays = yearMonth.lengthOfMonth();
        //每天单价   每个月一律按30天计算
        BigDecimal dayPrice = BigDecimalUtils.getBigAndBigDiv(zzgdMoneyPrice,new BigDecimal("31"),2);

        int zzgdFfMonth = 1;//总需发放月份  就算是9月份选房，也要多发一个月
        if (chooseYear == 2024) { //若2024年
            zzgdFfMonth = zzgdFfMonth + chooseMonth - 9;
        } else if (chooseYear == 2025) { //若是2025年 则2024年9、10、11、12月4个月过渡费都要发放,当月的按天发放；
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1;
        } else {
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1 + (chooseYear - 2025) * 12;
        }

        //总需发放过渡费金额
        BigDecimal zzgdMoney = BigDecimal.ZERO;
        zzgdMoney = BigDecimalUtils.getSum(
                BigDecimalUtils.getBigAndIntMul(dayPrice,11),
                BigDecimalUtils.getBigAndIntMul(zzgdMoneyPrice,2)
        ).setScale(2);
        return zzgdMoney;
    }

    /**
     * 停产停业金额计算
     * @param contract
     * @return
     */
    public BigDecimal zxgdMoney(Contract contract) {
        BigDecimal tcTyMoneyPrice = contract.getTcTyBzPrice();//据实单价(元/月)

        //房源签认时间年月日划分  只考虑2024年、2025，其它年份暂不考虑
        Date chooseHouseDate = contract.getChooseHouseDate();//选房时间
        Calendar chooseHouseCal = Calendar.getInstance();
        chooseHouseCal.setTime(chooseHouseDate);
        int chooseYear = chooseHouseCal.get(Calendar.YEAR);//选房年
        int chooseMonth = chooseHouseCal.get(Calendar.MONTH) + 1;//选房月
        int chooseDay = chooseHouseCal.get(Calendar.DATE);//选房日

        YearMonth yearMonth = YearMonth.of(chooseYear,chooseMonth);
        int yearMonthDays = yearMonth.lengthOfMonth();
        //每天单价   每个月一律按30天计算
        BigDecimal dayPrice = BigDecimalUtils.getBigAndBigDiv(tcTyMoneyPrice,new BigDecimal(yearMonthDays),2);

        int zzgdFfMonth = 1;//总需发放月份  就算是9月份选房，也要多发一个月
        if (chooseYear == 2024) { //若2024年
            zzgdFfMonth = zzgdFfMonth + chooseMonth - 9;
        } else if (chooseYear == 2025) { //若是2025年 则2024年9、10、11、12月4个月过渡费都要发放,当月的按天发放；
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1;
        } else {
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1 + (chooseYear - 2025) * 12;
        }
        //总需发放过渡费金额
        BigDecimal zxgdMoney = BigDecimal.ZERO;
        zxgdMoney = BigDecimalUtils.getSum(
                BigDecimalUtils.getBigAndIntMul(dayPrice,chooseDay),
                BigDecimalUtils.getBigAndIntMul(tcTyMoneyPrice,zzgdFfMonth)
        ).setScale(2);
        return zxgdMoney;
    }

    /**
     * 住宅过渡费金额计算备注
     * @param contract
     * @return
     */
    public String zzgdMoneyMemo(Contract contract) {
        BigDecimal zzgdMoneyPrice = BigDecimal.ZERO;//据实单价(元/月)
        //临时安置补助单价 都是翻倍数据(元/月)
        BigDecimal lsAzBzPrice = BigDecimalUtils.getBigAndBigMul(contract.getLsAzBzPrice(),new BigDecimal("2"));
        //临时安置补助增加部分单价 都是翻倍数据(元/月)
        BigDecimal lsAzBzZjPrice = BigDecimalUtils.getBigAndBigMul(contract.getLsAzBzZjPrice(),new BigDecimal("2"));
        //临时安置补助单价 + 临时安置增加单价
        BigDecimal lsAzBzPriceTotal = BigDecimalUtils.getSum(lsAzBzPrice,lsAzBzZjPrice);

        if (lsAzBzPriceTotal.compareTo(new BigDecimal("1000")) <= 0) {//当总单价小于1000 则实际单价及时合计单价
            zzgdMoneyPrice = lsAzBzPriceTotal;
        } else {
            if (lsAzBzPrice.compareTo(new BigDecimal("1000")) >= 0) {//若是正常单价大于1000 则按正常单价计算
                zzgdMoneyPrice = lsAzBzPrice;
            } else {//若小于1000
                if (lsAzBzPriceTotal.compareTo(new BigDecimal("1000")) > 0) {
                    zzgdMoneyPrice = new BigDecimal("1000");
                } else {
                    zzgdMoneyPrice = lsAzBzPriceTotal;
                }
            }
        }

        //房源签认时间年月日划分  只考虑2024年、2025，其它年份暂不考虑
        Date chooseHouseDate = contract.getChooseHouseDate();//选房时间
        Calendar chooseHouseCal = Calendar.getInstance();
        chooseHouseCal.setTime(chooseHouseDate);
        int chooseYear = chooseHouseCal.get(Calendar.YEAR);//选房年
        int chooseMonth = chooseHouseCal.get(Calendar.MONTH) + 1;//选房月
        int chooseDay = chooseHouseCal.get(Calendar.DATE);//选房日

        YearMonth yearMonth = YearMonth.of(chooseYear,chooseMonth);
        int yearMonthDays = yearMonth.lengthOfMonth();
        //每天单价   每个月一律按30天计算
        BigDecimal dayPrice = BigDecimalUtils.getBigAndBigDiv(zzgdMoneyPrice,new BigDecimal(yearMonthDays),2);
        BigDecimal dayPriceYz = BigDecimalUtils.getBigAndBigDiv(zzgdMoneyPrice,new BigDecimal(31),2);

        int zzgdFfMonth = 1;//总需发放月份  就算是9月份选房，也要多发一个月
        if (chooseYear == 2024) { //若2024年
            zzgdFfMonth = zzgdFfMonth + chooseMonth - 9;
        } else if (chooseYear == 2025) { //若是2025年 则2024年9、10、11、12月4个月过渡费都要发放,当月的按天发放；
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1;
        } else {
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1 + (chooseYear - 2025) * 12;
        }

        //总需发放过渡费金额
        StringBuffer zzgdMoneyMemo = new StringBuffer("");
        zzgdMoneyMemo.append(zzgdMoneyPrice + "*" + zzgdFfMonth + "+" + dayPrice + "*" + chooseDay);
        zzgdMoneyMemo.append("=" + zzgdMoney(contract) + "元");
        //一中过渡费计算说明
        StringBuffer zzgdMoneyYzMemo = new StringBuffer("");
        zzgdMoneyYzMemo.append(zzgdMoneyPrice + "*" + "2" + "+" + dayPriceYz + "*" + "11");
        zzgdMoneyYzMemo.append("=" + zzgdMoney(contract) + "元");


        return zzgdMoneyMemo.toString();
    }

    /**
     * 一中住宅过渡费金额计算备注
     * @param contract
     * @return
     */
    public String zzgdMoneyYzMemo(Contract contract) {
        BigDecimal zzgdMoneyPrice = BigDecimal.ZERO;//据实单价(元/月)
        //临时安置补助单价 都是翻倍数据(元/月)
        BigDecimal lsAzBzPrice = BigDecimalUtils.getBigAndBigMul(contract.getLsAzBzPrice(),new BigDecimal("2"));
        //临时安置补助增加部分单价 都是翻倍数据(元/月)
        BigDecimal lsAzBzZjPrice = BigDecimalUtils.getBigAndBigMul(contract.getLsAzBzZjPrice(),new BigDecimal("2"));
        //临时安置补助单价 + 临时安置增加单价
        BigDecimal lsAzBzPriceTotal = BigDecimalUtils.getSum(lsAzBzPrice,lsAzBzZjPrice);

        if (lsAzBzPriceTotal.compareTo(new BigDecimal("1000")) <= 0) {//当总单价小于1000 则实际单价及时合计单价
            zzgdMoneyPrice = lsAzBzPriceTotal;
        } else {
            if (lsAzBzPrice.compareTo(new BigDecimal("1000")) >= 0) {//若是正常单价大于1000 则按正常单价计算
                zzgdMoneyPrice = lsAzBzPrice;
            } else {//若小于1000
                if (lsAzBzPriceTotal.compareTo(new BigDecimal("1000")) > 0) {
                    zzgdMoneyPrice = new BigDecimal("1000");
                } else {
                    zzgdMoneyPrice = lsAzBzPriceTotal;
                }
            }
        }

        //房源签认时间年月日划分  只考虑2024年、2025，其它年份暂不考虑
        Date chooseHouseDate = contract.getChooseHouseDate();//选房时间
        Calendar chooseHouseCal = Calendar.getInstance();
        chooseHouseCal.setTime(chooseHouseDate);
        int chooseYear = chooseHouseCal.get(Calendar.YEAR);//选房年
        int chooseMonth = chooseHouseCal.get(Calendar.MONTH) + 1;//选房月
        int chooseDay = chooseHouseCal.get(Calendar.DATE);//选房日

        YearMonth yearMonth = YearMonth.of(chooseYear,chooseMonth);
        int yearMonthDays = yearMonth.lengthOfMonth();
        //每天单价   每个月一律按30天计算
        BigDecimal dayPrice = BigDecimalUtils.getBigAndBigDiv(zzgdMoneyPrice,new BigDecimal(yearMonthDays),2);
        BigDecimal dayPriceYz = BigDecimalUtils.getBigAndBigDiv(zzgdMoneyPrice,new BigDecimal(31),2);

        int zzgdFfMonth = 1;//总需发放月份  就算是9月份选房，也要多发一个月
        if (chooseYear == 2024) { //若2024年
            zzgdFfMonth = zzgdFfMonth + chooseMonth - 9;
        } else if (chooseYear == 2025) { //若是2025年 则2024年9、10、11、12月4个月过渡费都要发放,当月的按天发放；
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1;
        } else {
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1 + (chooseYear - 2025) * 12;
        }

        //总需发放过渡费金额
        StringBuffer zzgdMoneyMemo = new StringBuffer("");
        zzgdMoneyMemo.append(zzgdMoneyPrice + "*" + zzgdFfMonth + "+" + dayPrice + "*" + chooseDay);
        zzgdMoneyMemo.append("=" + zzgdMoney(contract) + "元");
        //一中过渡费计算说明
        StringBuffer zzgdMoneyYzMemo = new StringBuffer("");
        zzgdMoneyYzMemo.append(zzgdMoneyPrice + "*" + "2" + "+" + dayPriceYz + "*" + "11");
        zzgdMoneyYzMemo.append("=" + zzgdMoneyYz(contract) + "元");


        return zzgdMoneyYzMemo.toString();
    }

    /**
     * 停产停业金额计算备注
     * @param contract
     * @return
     */
    public String zxgdMoneyMemo(Contract contract) {
        BigDecimal tcTyMoneyPrice = contract.getTcTyBzPrice();//据实单价(元/月)

        //房源签认时间年月日划分  只考虑2024年、2025，其它年份暂不考虑
        Date chooseHouseDate = contract.getChooseHouseDate();//选房时间
        Calendar chooseHouseCal = Calendar.getInstance();
        chooseHouseCal.setTime(chooseHouseDate);
        int chooseYear = chooseHouseCal.get(Calendar.YEAR);//选房年
        int chooseMonth = chooseHouseCal.get(Calendar.MONTH) + 1;//选房月
        int chooseDay = chooseHouseCal.get(Calendar.DATE);//选房日

        YearMonth yearMonth = YearMonth.of(chooseYear,chooseMonth);
        int yearMonthDays = yearMonth.lengthOfMonth();
        //每天单价   每个月一律按30天计算
        BigDecimal dayPrice = BigDecimalUtils.getBigAndBigDiv(tcTyMoneyPrice,new BigDecimal(yearMonthDays),2);

        int zzgdFfMonth = 1;//总需发放月份  就算是9月份选房，也要多发一个月
        if (chooseYear == 2024) { //若2024年
            zzgdFfMonth = zzgdFfMonth + chooseMonth - 9;
        } else if (chooseYear == 2025) { //若是2025年 则2024年9、10、11、12月4个月过渡费都要发放,当月的按天发放；
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1;
        } else {
            zzgdFfMonth = zzgdFfMonth + 4 + chooseMonth - 1 + (chooseYear - 2025) * 12;
        }
        //总需发放过渡费金额
        StringBuffer zxgdMoneyMemo = new StringBuffer("");
        zxgdMoneyMemo.append(tcTyMoneyPrice + "*" + zzgdFfMonth + "+" + dayPrice + "*" + chooseDay);
        zxgdMoneyMemo.append("=" + zxgdMoney(contract) + "元");
        return zxgdMoneyMemo.toString();
    }

    /**
     * 征收项目数据配置表单
     *
     * @param request
     * @param modelMap
     */
    @RequestMapping("dataForm")
    public void dataForm(HttpServletRequest request, ModelMap modelMap) {
        int contractId = ParamUtils.getInt(request, "contractId", 0);
        Contract contract = this.contractService.findOne(contractId);
        Parameter parameter = new Parameter();
        if (contract.getParameter() == null) {
            parameter = new Parameter();
        } else {
            parameter = this.parameterService.findOne(contract.getParameter().getId());
        }
        Precondition.checkSqdsArguement(parameter != null, "未找到相关参数！");
        //住宅
        List<OverAreaPriceNew> overAreaPriceNewList = this.overAreaPriceNewService.getOverAreaPriceNewListByParameterId(parameter.getId());
        //商业扩购面积【手动登记】
        List<SyKgInfo> syKgInfoList = this.syKgInfoService.getSyKgInfoListByParameterId(parameter.getId());
        //若为空则初始化 参数名称
        //格式化当前日期后再存入系统
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date now = new Date();
        String formattedDate = sdf.format(now);
        modelMap.addAttribute("name",formattedDate + "_【" + contract.getId() + "】_【" + contract.getContractCode() + "】");
        modelMap.addAttribute("syKgInfoList",syKgInfoList);
        modelMap.addAttribute("parameter", parameter);
        modelMap.addAttribute("overAreaPriceNewList", overAreaPriceNewList);
        modelMap.addAttribute("contract",contract);
    }

    /**
     * 参数配置数据保存
     *
     * @param request
     * @return
     * @throws AjaxException
     */
    @RequestMapping("dataFormSave")
    @ResponseBody
    public synchronized Response dataFormSave(HttpServletRequest request) throws AjaxException {
        Response response = this.parameterService.dataFormSySave(request);
        return response;
    }




}